﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataStructure;
using System.Collections;

namespace DataStructureCaller
{
    class Program
    {

        public static void MySetTest()
        {
            MySet setA = new MySet();
            MySet setB = new MySet();
            setA.Add("milk");
            setA.Add("eggs");
            setA.Add("bacon");
            setA.Add("cereal");
            setB.Add("bacon");
            setB.Add("eggs");
            setB.Add("bread");
            MySet setC = new MySet();
            setC = setA.Union(setB);
            Console.WriteLine();
            Console.WriteLine("A:" + setA.ToString());
            Console.WriteLine("B:" + setB.ToString());
            Console.WriteLine("A union B:" + setC.ToString());
            setC = setA.Intersection(setB);
            Console.WriteLine("A intersect B: " +
            setC.ToString());
            setC = setA.Difference(setB);
            Console.WriteLine("A diff B:" + setC.ToString());
            setC = setB.Difference(setA);
            Console.WriteLine("B diff A:" + setC.ToString());
            if (setB.Subset(setA))
                Console.WriteLine("b is a subset of a");
            else
                Console.WriteLine("b is not a subset of a");
        }
        static void Main(string[] args)
        {
            
            return;
            byte[] ByteSet = new byte[] { 1, 2, 3, 4, 5 };
            BitArray BitSet = new BitArray(ByteSet);
        }


        public static void PerfTestingOfSorting()
        {
            Console.WriteLine("test result:{0}", 10);
            Perf(10);

            Console.WriteLine("test result:{0}", 100);
            Perf(100);

            Console.WriteLine("test result:{0}", 1000);
            Perf(1000);

            Console.WriteLine("test result:{0}", 10000);
            Perf(10000);
        }

        private static void Perf(int numItems)
        {
            Timing sortTime = new Timing();
            Random rnd = new Random(numItems);
            CArray theArray = new CArray(numItems);
            for (int i = 0; i < numItems; i++)
                theArray.Insert((int)(rnd.NextDouble() * 10000));

            sortTime.StartTime();
            for (int j = 0; j < 1; j++)
            {
                theArray.SelectionSort();
            }
            sortTime.StopTime();

            Console.WriteLine("Time for Selection sort: " + sortTime.Result().TotalMilliseconds);
            theArray.Clear();

            for (int i = 0; i < numItems; i++)
                theArray.Insert((int)(rnd.NextDouble() * 100));

            sortTime.StartTime();
            theArray.BubbleSort();
            sortTime.StopTime();
            Console.WriteLine("Time for Bubble sort: " + sortTime.Result().TotalMilliseconds);
            theArray.Clear();


            for (int i = 0; i < numItems; i++)
                theArray.Insert((int)(rnd.NextDouble() * 100));
            sortTime.StartTime();
            theArray.InsertionSort();
            sortTime.StopTime();
            Console.WriteLine("Time for Insertion sort: " + sortTime.Result().TotalMilliseconds);
        }

    }
}
